﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MillerApp.UserControls;
using MillerApp.DataContract.MillerDB;
using MillerApp.DataAccess.MillerDB;
using MillerApp.Common;
using MillerApp.DataContract.Common;

namespace MillerApp.Stock.Maintain
{
    public partial class StockqtReadinfoMaintain : EnitityFormBase
    {
        public StockqtReadinfoMaintain()
        {
            InitializeComponent();
        }

        public StockqtreadinfosEntity Entity { get; set; }
        private string userid = string.Empty;

        private void StockqtReadinfoMaintain_Load(object sender, EventArgs e)
        {
            WinEffect.SetMid(this);
            object obj = Entity;
            if (obj != null)
            {
                userid = Entity.userid;
            }
            base.Mapping2Control(ref obj);
            this.maintainActionControl1.ActionMethod += new DelegateMethod(maintainActionControl1_ActionMethod);
        }

        void maintainActionControl1_ActionMethod()
        {
            if (this.ActionTypeCode == UserControls.Enums.ActionType.Deleted)
            {
                StockqtreadinfosManager.DeleteStockqtreadinfos(Entity.id);
                return;
            }

            if (this.ActionTypeCode == UserControls.Enums.ActionType.AddNew)
            {
                string userid = Entity.userid;
                Entity = new StockqtreadinfosEntity();
                Entity.userid = userid;
                object obj = Entity;
                base.Mapping2Entity(ref obj);
                StockqtreadinfosManager.InsertStockqtreadinfos(Entity);
            }
            if (this.ActionTypeCode == UserControls.Enums.ActionType.Modify)
            {
                object obj = Entity;
                base.Mapping2Entity(ref obj);
                StockqtreadinfosManager.UpdateStockqtreadinfos(Entity);
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
    }
}
